<?php

namespace addons\tools\library\ali;

class Base
{
    protected $accessKeyID = 'LTAI5tDu1JeoFc76HKGH7U1m';

    protected $accessKeySecret = 'q6TnuHHqspa3Xo8pDQFOLhIcnnUnx5';

    protected $apiHttpMethod = "POST";
    // API访问域名，与类目相关，具体类目的API访问域名请参考：https://help.aliyun.com/document_detail/143103.html
    /**
     * @var string
     */
    protected $apiEndPoint = "";
    /**
     * @var string
     */
    protected $regionId = 'cn-shanghai.aliyuncs.com';
    /**
     * @var string
     */
    protected $action = '';

    // API版本，与类目相关，具体类目的API版本请参考：https://help.aliyun.com/document_detail/464194.html
    protected $apiVesrion = "2019-09-30";

    const DF       = "Y-m-d\TH:i:s\Z";
    const EndPoint = 'cn-shanghai.aliyuncs.com';

//    protected function
    protected function specialUrlEncode($value)
    {
        return str_replace(array("+", "*", "%7E"), array("%20", "%2A", "~"), rawurlencode($value));
    }

    protected function sign($accessSecret, $stringToSign)
    {
        return base64_encode(hash_hmac("sha1", $stringToSign, $accessSecret, true));
    }

    protected function uploadConfig($key)
    {
        $config = [
            //图片上色
            'ColorizeImage'            => [
                'Parent'  => 'imageenhan',
                'Version' => '2019-09-30',
            ],
            //人脸增强与修复
            'EnhanceFace'              => [
                'Parent'  => 'facebody',
                'Version' => '2019-12-30',
            ],
            //身份证识别
            'RecognizeIdentityCard'    => [
                'Parent'  => 'ocr',
                'Version' => '2019-12-30',
            ],
            //图片清晰度无损放大
            'MakeSuperResolutionImage' => [
                'Parent'  => 'imageenhan',
                'Version' => '2019-09-30',
                'Params'  => 'Url'
            ],
            //商品分割
            'SegmentCommodity'         => [
                'Parent'  => 'imageseg',
                'Version' => '2019-12-30',
            ],
            //图像标志擦除
            'RemoveImageWatermark'     => [
                'Parent'  => 'imageenhan',
                'Version' => '2019-09-30',
            ],
            //图像裁剪
            'ChangeImageSize'          => [
                'Parent'  => 'imageenhan',
                'Version' => '2019-09-30',
                'Params'  => 'Url',
            ],
            //菜品识别
            'RecognizeFood'            => [
                'Parent'  => 'imagerecog',
                'Version' => '2019-09-30',
            ],
            //人物动漫化
            'GenerateHumanAnimeStyle'  => [
                'Parent'  => 'facebody',
                'Version' => '2019-12-30',
            ],
            //人像素描风格化
            'GenerateHumanSketchStyle' => [
                'Parent'  => 'facebody',
                'Version' => '2019-12-30',
            ],
            //人脸信息脱敏
            'BlurFace'                 => [
                'Parent'  => 'facebody',
                'Version' => '2019-12-30',
            ],
            //人脸美型
            'FaceTidyup'               => [
                'Parent'  => 'facebody',
                'Version' => '2019-12-30',
            ],
            //人脸滤镜
            'FaceFilter'               => [
                'Parent'  => 'facebody',
                'Version' => '2019-12-30',
            ],
            //人脸美妆
            'FaceMakeup'               => [
                'Parent'  => 'facebody',
                'Version' => '2019-12-30',
            ],
            //人脸美颜
            'FaceBeauty'               => [
                'Parent'  => 'facebody',
                'Version' => '2019-12-30',
            ],
            //智能瘦脸
            'LiquifyFace'              => [
                'Parent'  => 'facebody',
                'Version' => '2019-12-30',
            ],
            //智能美肤
            'RetouchSkin'              => [
                'Parent'  => 'facebody',
                'Version' => '2019-12-30',
            ],
            //高清人体分割
            'SegmentHDBody'            => [
                'Parent'  => 'imageseg',
                'Version' => '2019-12-30',
            ],
            //人体分割
            'SegmentBody'              => [
                'Parent'  => 'imageseg',
                'Version' => '2019-12-30',
            ],
            //图像色彩增强
            'EnhanceImageColor'        => [
                'Parent'  => 'imageenhan',
                'Version' => '2019-09-30',
            ],
            //图像人脸融合
            'MergeImageFace'           => [
                'Parent'  => 'facebody',
                'Version' => '2019-12-30',
            ],
            //服饰分割
            'SegmentCloth'             => [
                'Parent'  => 'imageenhan',
                'Version' => '2019-09-30',
            ],
            //图像人脸融合
            'ErasePerson'              => [
                'Parent'  => 'imageenhan',
                'Version' => '2019-09-30',
            ],
            //图像字幕擦除
            'RemoveImageSubtitles'     => [
                'Parent'  => 'imageenhan',
                'Version' => '2019-09-30',
            ]
        ];
        return $config[$key];
    }

}